\documentclass[a4paper]{article}
\usepackage{xltxtra}
\usepackage{graphicx}
\usepackage{fontspec}
\usepackage{cite}
\usepackage{geometry}
\usepackage{amsmath}

\geometry{left=20mm,right=20mm,top=20mm,bottom=20mm}
\begin{document}  

\title{HW1: Programming}  
\author{Zhou Jiang 3220101339}   
\date{2024-10-7}  
\maketitle  

\section{A:}  
The derivative of the function is approximated by the method of approximation in the \texttt{Function.hpp} file. Implement the bisection method, Newton method, and secant method in the \texttt{EquationSolver.hpp} file.

\section{B:}  
The experimental results are as follows:
\begin{verbatim}
    B(1):Solving x^{-1} - \tan x on [0, \pi/2]\\
    A root is: 0.860334\\
    B(2):Solving x^{-1} - \2^(x) on [0, 1]\\
    A root is: 0.641186\\
    B(3):Solving 2^(-x) + \e^(x) + \2cos(x) - \6 on [1, 3]\\
    A root is: 1.82938\\
    B(4):Solving (x^3 + 4x^2 + 3x + 5) \ (2x^3-9x^2+18x-2) on [0, 4]\\
    A root is: 0.117877
\end{verbatim}
\section{C:} 
The experimental results are as follows:
\begin{verbatim}
    C:Solving x = tan(x) on [4.5, 7.7]
    A root is: 4.49341
\end{verbatim}
\section{D:} 
The experimental results are as follows:
\begin{verbatim}
    D(1):Solving sin(x/2) - 1 with x0=1 , x1=Pi/2
    A root is: 3.14097
    D(1):Solving sin(x/2) - 1 with x0=1 , x1=Pi/4
    A root is: 3.14084
    D(2):Solving e^x - tan(x) with x0=1 , x1=1.4
    A root is: 1.30633
    D(2):Solving e^x - tan(x) with x0=0.5 , x1=2.0
    A root is: -3.09641
    D(3):Solving x^3-12x^2+3x+1 with x0=0 , x1=-0.5
    A root is: -0.188685
    D(3):Solving x^3-12x^2+3x+1 with x0=0.1 , x1=-1.0
    A root is: -0.188685
\end{verbatim}
The effect of different initial values:\\
1.Secant converges to different roots depending on the initial value. This effect is especially pronounced for functions with multiple roots.\\
2.If the initial guess is too far away from any roots, or too close not to get close to the roots, the method may not converge or take a long time.
\section{E:} 
The experimental results are as follows:
\begin{verbatim}
    E:Find the depth of water in the trough to within 0.01ft by each of the three implementations in A
    The depth of water is: 0.17
\end{verbatim}
\section{F:} 
The experimental results are as follows:
\begin{verbatim}
    F(1):Solving A*sin(x)*cos(x)+B*pow(sin(x), 2)-C*cos(x)-E*sin(x)
    A root is: 32.9722
    F(2)Solving A*sin(x)*cos(x)+B*pow(sin(x), 2)-C*cos(x)-E*sin(x) with D=30
    A root is: 33.1689
    F(3):Solving A*sin(x)*cos(x)+B*pow(sin(x), 2)-C*cos(x)-E*sin(x) with another initial value=32.9
    A root is: 32.9722
    Solving A*sin(x)*cos(x)+B*pow(sin(x), 2)-C*cos(x)-E*sin(x) with another initial value=30
    A root is: 32.9722
    Solving A*sin(x)*cos(x)+B*pow(sin(x), 2)-C*cos(x)-E*sin(x) with another initial value=-1000
    A root is: 32.9722
    Solving A*sin(x)*cos(x)+B*pow(sin(x), 2)-C*cos(x)-E*sin(x) with another initial value=-1e100
    A root is: -4.59891e+96

\end{verbatim}
The reason:Using the secant method with a significantly different initial guess will yield potentially a different root.
\end{document}  
